import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class VideoPlayerListDemoPage extends GetView<VideoPlayerListDemoController> {
  const VideoPlayerListDemoPage({super.key});

  // 主视图
  Widget _buildView() {
    return ListView.builder(
      controller: controller.state.sc,
      itemBuilder: (context, index) {
        final md = controller.state.list![index];
        return VideoPlayerListCell(md);
      },
      itemCount: controller.state.list?.length ?? 0,
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<VideoPlayerListDemoController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("视频列表滑动到可视位置自动播放")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
